package com.handinglian.task.enums;

public enum CalllStateEnum {
    UNKNOWN(0,""),
    WAIT_TO_CALL(1,"待呼"),
    ANSWER(2,"已通"),
    NOT_ANSWER(3,"未接");

    public static CalllStateEnum valueOfOrdinal(Integer ordinal) {
        return ordinal == null || ordinal >= values().length ? UNKNOWN : values()[ordinal];
    }
    public static CalllStateEnum valueOfDesc(String desc) {
        for(CalllStateEnum calllStateEnum: CalllStateEnum.values()){
            if(desc.equals(calllStateEnum.getDescription())){
                return calllStateEnum;
            }
        }
        return UNKNOWN;
    }
    public static CalllStateEnum valueOfKey(Integer key){
        for(CalllStateEnum calllStateEnum : CalllStateEnum.values()){
            if(calllStateEnum .getKey()==key){
                return calllStateEnum;
            }
        }
        return UNKNOWN;
    }
    private final Integer key;
    private final String description;

    CalllStateEnum(Integer key, String description) {
        this.key = key;
        this.description = description;
    }

    public Integer getKey() {
        return key;
    }
    public String getDescription() {
        return this.description;
    }
}
